import threading
import time

# 代表鱼的锁
mutex_Yu = threading.Lock()
# 代表熊掌的锁
mutex_Xiongzhang = threading.Lock()


class MyThread1(threading.Thread):

    def run(self):
        mutex_Yu.acquire()  # 得到🐟
        print('线程1已经得到鱼了')
        time.sleep(1)

        mutex_Xiongzhang.acquire()
        print('线程1得到熊掌')
        mutex_Xiongzhang.release()
        mutex_Yu.release()


class MyThread2(threading.Thread):

    def run(self):
        mutex_Xiongzhang.acquire()
        print('线程2已经得到熊掌了')
        time.sleep(1)

        mutex_Yu.acquire()
        print('线程2已经得到🐟了')
        mutex_Yu.release()
        mutex_Xiongzhang.release()

if __name__ == '__main__':
    t1 = MyThread1()
    t2 = MyThread2()
    t1.start()
    t2.start()
